package com.gange.config;

import com.gange.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//让spring 管理起来当前类，spring容器中可以使用对象，当前类是一个配置类
@Configuration
//对拦截器进行配置
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;
    //管理拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //表示拦截器拦截所有的请求
       registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
    }
}
